//
//  SliderTypeTwoViewController.m
//  SpecialEffectsProject
//
//  Created by 蓓蕾 on 2021/11/4.
//

#import "SliderTypeTwoViewController.h"
#import <MapKit/MapKit.h>
#define cellH 150                       //cell高度
#define cellCount 6                     //cell高度
#import "XDSTableView.h"

@interface SliderTypeTwoViewController ()<MKMapViewDelegate,UITableViewDelegate,UITableViewDataSource>


@property (nonatomic, weak) MKMapView *mapView;
@property (nonatomic, weak) UITableView *tableView;

@end

@implementation SliderTypeTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    // Do any additional setup after loading the view.
}

- (void)setupUI {
    // 地图部分界面
    MKMapView *mapView = [[MKMapView alloc]initWithFrame:self.view.bounds];
    mapView.delegate = self;
    mapView.mapType = MKMapTypeStandard;
    self.mapView = mapView;
    [self.view addSubview:mapView];
    
    
    // 表格部分

    //20为状态栏高度；tableview设置的大小要和view的大小一致
    XDSTableView *tableView = [[XDSTableView alloc] initWithFrame:CGRectMake(0, 120, kScreenWidth, kScreenHeight - 120) style:UITableViewStyleGrouped];
    
    //tableview不延时
//    self.tableView.delaysContentTouches = NO;
//    for (UIView *subView in self.tableView.subviews) {
//        if ([subView isKindOfClass:[UIScrollView class]]) {
//            ((UIScrollView *)subView).delaysContentTouches = NO;
//            tableScrollView = subView;
//            subView.backgroundColor = [UIColor orangeColor];
//        }
//    }
//    UIView *bgView = [[UIView alloc] init];
//    tableView.backgroundView = bgView;
//    bgView.backgroundColor = [UIColor orangeColor];
//    UIView *bgView = [[UIView alloc] init];
//    [self.view addSubview:bgView];
//    bgView.backgroundColor = [UIColor orangeColor];
    //tableview下移
    tableView.contentInset = UIEdgeInsetsMake(kScreenHeight - 100 - 120, 0, 0, 0);
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0.001)];//去掉头部空白
    tableView.backgroundColor = [UIColor clearColor];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.showsVerticalScrollIndicator = NO;
    tableView.sectionHeaderHeight = 0.0;//消除底部空白
    tableView.sectionFooterHeight = 0.0;//消除底部空白
    self.tableView = tableView;
    [self.view addSubview:tableView];
//    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(self.view.mas_left).mas_offset(0);
//        make.right.mas_equalTo(self.view.mas_right).mas_offset(0);
//        make.top.mas_equalTo(tableScrollView.mas_top).mas_offset(0);
//        make.bottom.mas_equalTo(self.view.mas_bottom).mas_offset(0);
//    }];
    
}



#pragma mark - 选中cell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击了cell");
}

#pragma mark - cell高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return cellH;
}

#pragma mark - cell数量
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return cellCount;
}

#pragma mark - 每个cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //cell颜色（红蓝循环）
    if(indexPath.row%2==0){
        cell.backgroundColor = [UIColor blueColor];
    }else{
        cell.backgroundColor = [UIColor redColor];
    }
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
